<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- 了解 -->
      <h2>全局注册组件</h2>
      <my-component></my-component>
    </div>

    <script src="./Vue3.js"></script>
    <script>
      const { createApp } = Vue;

      // 先得到根组件实例
      const app = createApp({
        data() {
          return {};
        },
      });

      // 全局注册组件
      app.component(
        // 注册的名字
        "MyComponent",
        // 组件的实现
        {
          template: `
            <div>child子组件</div>
          `,
        }
      );

      app.mount("#app");
    </script>
  </body>
</html>
